

import React, { Component } from "react";
import { Form, Input, Row, Col, Button, Select, Divider, DatePicker, Upload, Switch, Icon, Tooltip, message } from 'antd';
import SaasModal from '../../../../components/display/SaasModal';
import {prefixFile,fileImport} from '../../../../fetch/fetchApi';
const createForm = Form.create;
// const {TextArea} = Input;

class UploadPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            refresh:0,
            params:{},
            fileList:[],
        };
    }


    render() {
        const props = {
            name: 'file',
            action: `${prefixFile}/import.do?serviceName=stubGroupImport`,
            headers: {
                authorization: 'authorization-text',
            },
            onChange:(info)=> {
                console.log(info);
                if (info.file.status === 'done') {
                    // message.success(`${info.file.name} 上传成功`);
                    this.setState({
                        fileList:info.file.response
                    },()=>{
                        this.props.handleCancel();
                        this.props.getFileList(this.state.fileList);
                    })
                  } else if (info.file.status === 'error') {
                    message.error(`${info.file.name} 上传失败`);
                  }
            },
        };
        return(
            <SaasModal visible={this.props.visible} handleCancel={this.props.handleCancel} title={'批量上传'}>
                <div style={{display:'flex',justifyContent:'center'}}>
                    <Upload {...props}>
                        <Button style={{marginRight:8}} onClick={()=>{this.setState({visible4Up:true})}}>上传文件</Button>
                    </Upload>
                    <a href={`${prefixFile}/templates/桩群导入模板.xls`}>
                    <Button style={{marginRight:8}}>下载模板</Button>
                    </a>
                </div>
            </SaasModal>
        )
    }
}
UploadPage = createForm()(UploadPage);
export default UploadPage;